<?php
include_once __DIR__.'/config/env_config.php';
include_once __DIR__.'/lib/Helper.php';

$ticketId = $_GET['ticket_id'];
if (empty($ticketId)) {
    echo 'ticket id is empty';
    die;
}

$saTicketIdsFile = __DIR__."/data/special_attention_ticket_ids.json";
$saTicketDataFile = __DIR__."/data/special_attention_tickets.json";

$saTicketIds = array();
if (file_exists($saTicketIdsFile)) {
    $saTicketIds = json_decode(file_get_contents($saTicketIdsFile), true);
}
$saTicketIds[$ticketId] = $ticketId;
file_put_contents($saTicketIdsFile, json_encode($saTicketIds));

// update
$oldSaTickets = json_decode(file_get_contents($saTicketDataFile), true);
$saTickets = Helper::specifiedTickets(array($ticketId));
$saTickets = $oldSaTickets + $saTickets;
file_put_contents($saTicketDataFile, json_encode($saTickets));
echo 'success';
